<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        .item {
            text-align: center;
        }
    </style>
</head>

<body>
    <!-- 下拉刷新
        van-pull-refresh
            v-model="boolean值"  true:正在执行刷新中(平时不需要修改成true,因为我们下拉, 过程中该值它会自动变成true),false:刷新动作完成
            @refresh="执行相应的刷新代码"          
   -->
    <div id="app">
        <van-pull-refresh v-model="loading" @refresh="refresh">
            <ul>
                <li class="item" v-for="(item,index) in arr" :key="index"> {{item}} </li>
            </ul>
        </van-pull-refresh>
    </div>
    <!-- 引入样式文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.10/lib/index.css" />


    <!-- 引入 Vue 和 Vant 的 JS 文件 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6/dist/vue.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vant@2.10/lib/vant.min.js"></script>
    <script>
        new Vue({
            el: "#app",
            data: {
                loading: false,
                arr: [1, 2, 3, 4, 5, 6]
            },
            methods: {
                refresh() {
                    /* 调用接口,更新arr数据 */
                    setTimeout(() => {
                        this.arr.push(Math.random() * 999);
                        this.loading = false;
                    }, 1000)
                }
            },
        });
    </script>
</body>

</html>